#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(int* e1, int* e2)
{
	return *e2 - *e1;
}
void test()
{
	int nums[] = { 3,30,34,5,9 };
	int numsSize = sizeof(nums) / sizeof(nums[0]);
	int tmp[100] = { 0 };
	memcpy(tmp, nums, 4 * numsSize);
	for (int i = 0; i < numsSize; ++i)
	{
		while (tmp[i] > 9)
		{
			tmp[i] /= 10;
		}
	}
	qsort(tmp, numsSize, 4, cmp);
	int max = 0;
	char s[100] = { 0 };
	int index = 0;
	for (int i = 0; i < numsSize; ++i)
	{
		int pos = 0;
		for (int j = 0; j < numsSize; ++j)
		{
			int cmp = nums[j];
			while (cmp > 9)
			{
				cmp /= 10;
			}
			if (tmp[i] == cmp)
			{
				max = max > nums[j] ? max : nums[j];
				pos = j;
			}
		}
		nums[pos] = -1;
		char arr[10] = { 0 };
		int indexS = 0;
		while (max)
		{
			arr[indexS++] = max % 10 + '0';
			max /= 10;
		}
		for (int j = 0; j < indexS / 2; ++j)
		{
			char tmp = arr[j];
			arr[j] = arr[indexS - 1 - j];
			arr[indexS - 1 - j] = tmp;
		}
		strcat(s, arr);
	}
}
int main()
{			 
	test();
	return 0;
}